package bizlogic.borrowinfo;

import java.util.List;

import bizlogic.borrowinfo.domain.BorrowInfo;
import dao.BorrowInfoDao;


public class BorrowInfoService
{
    BorrowInfoDao borrowInfoDao = new BorrowInfoDao();

    /*
     * 添加借书信息
     */
    public String addBorrowInfo(BorrowInfo borrowInfo) {
        int addBorrowInfo = borrowInfoDao.addBorrowInfo(borrowInfo);
        if (addBorrowInfo == 1) {
            return "借书成功";
        } else {
            return "借书失败";
        }

    }

    /*
     * 更新借书信息
     */
    public String updateBorrowInfo(BorrowInfo borrowInfo) {
        int updateBorrowInfo = borrowInfoDao.updateBorrowInfo(borrowInfo);
        if (updateBorrowInfo != 0) {
            return "更新成功";
        } else {
            return "更新失败";
        }
    }

    /*
     * 删除借书信息（传入单个图书id删除单条数据）
     */
    public String deleteBorrowInfoByBorrowId(String borrowId) {
        int deleteBorrowInfoByBorrowId = borrowInfoDao.deleteBorrowInfoByBorrowId(borrowId);
        if (deleteBorrowInfoByBorrowId != 0) {
            return "更新成功";
        } else {
            return "更新失败";
        }

    }

    /*
     * 根据借书id查询借书信息
     */
    public BorrowInfo queryBorrowInfoByID(String borrowId) {
        return borrowInfoDao.queryBorrowInfofoByID(borrowId);
    }

    /*
     * 查询借书信息列表（返回查询的实体集合）
     */
    public List<BorrowInfo> queryBorrowInfoByKeyWords(int pageIndex, int pageSize, String sortField, String sortOrder) {
        return borrowInfoDao.queryBorrowInfo(pageIndex, pageSize, sortField, sortOrder);
    }

    /*
     * 查询借书信息表中所有数据的条数
     */
    public int findLength() {
        return borrowInfoDao.findLength();
    }

    /*
     * getNextid获取下一个borrowid
     */
    public String getNextID() {

        return borrowInfoDao.getNextBorrowID();
    }

}
